package com.zdp.contentcenter.feignclient;

import com.zdp.contentcenter.domain.dto.user.UserDTO;
import com.zdp.contentcenter.feignclient.fallbackfactory.UserCenterFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @author sesshomaru
 * @date 2020/9/17
 */
// feing的细粒度配置的java代码方式使用到 @FeignClient(name = "user-center", configuration = UserCenterFeignConfiguration.class)
    // UserCenterFeignConfiguration是自定义的feign配置具体内容是修改feing的日志级别
// @FeignClient(name = "user-center", configuration = UserCenterFeignConfiguration.class)
    // 采用配置属性的方式完成，feign的细粒度配置，把feign直接修改会原来的样子
@FeignClient(name = "user-center",
        //fallback = UserCenterFeignClientFallback.class
        fallbackFactory = UserCenterFeignClientFallbackFactory.class
        )
public interface UserCenterFeignClient {

    /**
     * feign会自动构造成: http://user-center/users/{id} 并且去请求将返回的结果装换为UserDTO
     * @param id
     * @return
     */
    @GetMapping("/users/{id}")
    UserDTO findById(@PathVariable Integer id);
}
